import utils from '../utils'

function mergeLayerNames(layers) {
  return layers.reduce((memo, lyr) => {
    if (memo === null) {
      memo = lyr.name || null
    } else if (memo && lyr.name) {
      memo = utils.mergeNames(memo, lyr.name)
    }
    return memo
  }, null) || ''
}

export default {
  mergeLayerNames,
}